/**
 * 
 */
package com.jung.common;

import java.util.List;

import com.hp.util.ListPage;
import com.hp.util.PageContext;
import com.opensymphony.xwork2.ActionSupport;

/*
 * Copyright (c) 2010 Hewlett-Packard Company, Inc. All Rights Reserved.
 * This software is the confidential and proprietary information of 
 * Hewlett-Packard, Inc. ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Hewlett-Packard.
 * HP MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
 * THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
 * TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
 * PARTICULAR PURPOSE, OR NON-INFRINGEMENT. HP SHALL NOT BE LIABLE FOR
 * ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
 * DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
 */

/**
 *base action 继承actionSupport，用于实现通用的action操作和数据,其它的action需要继承它.
 *
 *@version $Revision: 1.1 $ 2010-3-19
 *@author daijiang mailto: jianglin.dai@hp.com
 */
public class BaseAction extends ActionSupport {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 7092517565006491462L;

	public static String SUCCESS = "success";

	public static String FAIL = "fail";

	public static String ERROR = "error";
	
	public static  String NULL="null";
	
	private String subMenuName="";
	
	private String mainMenuName="";

	/**
	 * @return
	 */
	public String getMainMenuName() {
		return mainMenuName;
	}

	/**
	 * @param mainMenuName
	 */
	public void setMainMenuName(String mainMenuName) {
		this.mainMenuName = mainMenuName;
	}

	/**
	 * @return
	 */
	public String getSubMenuName() {
		return subMenuName;
	}

	/**
	 * @param subMenuName
	 */
	public void setSubMenuName(String subMenuName) {
		this.subMenuName = subMenuName;
	}
	
	/**
	 * 创建分页上下文环境.
	 * @param pageContext 分页上下文 
	 * @param result  结果列表
	 * @param pageSize 分页大小
	 * @return
	 */
	protected PageContext createPageContext (PageContext pageContext, List result,int pageSize){
		if(pageContext!=null){
			if (pageContext.getPageNumber() != 0) {
				pageContext.setPage(new ListPage(result, pageContext
						.getPageNumber(), pageSize));
			}else{
				pageContext.setPage(new ListPage(result, 0, pageSize));
			}
		}
		return pageContext;
	}
	
}
